//
//  NewspaperCategoryCell.m
//  JianChaRiBao
//
//  Created by 常兴宇 on 13-10-29.
//  Copyright (c) 2013年 wzyk. All rights reserved.
//

#import "NewspaperCategoryCell.h"
#import "UIImageView+WebCache.h"
#import <QuartzCore/QuartzCore.h>

@interface NewspaperCategoryCell ()
{
    UIImageView * coverImageView;
    UILabel * coverLabel;
}

@end
@implementation NewspaperCategoryCell

- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        self.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleHeight| UIViewAutoresizingFlexibleTopMargin;
        coverImageView = [[[UIImageView alloc] initWithFrame:self.bounds] autorelease];
        coverImageView.layer.shadowColor = [UIColor blackColor].CGColor;
        coverImageView.layer.shadowOpacity = 0.45;
        coverImageView.layer.shadowOffset = CGSizeMake(0, 6);
        coverImageView.layer.shadowPath = [UIBezierPath bezierPathWithRect:coverImageView.bounds].CGPath;
        coverImageView.layer.masksToBounds = NO;
        [self.contentView addSubview:coverImageView];
        
        coverLabel = [[[UILabel alloc]initWithFrame:CGRectMake(0, self.bounds.size.height - 20, self.bounds.size.width, 20)] autorelease];
        coverLabel.backgroundColor = [UIColor blackColor];
        coverLabel.alpha = 0.7;
        coverLabel.textColor = [UIColor whiteColor];
        coverLabel.textAlignment = UITextAlignmentCenter;
        coverLabel.font = [UIFont systemFontOfSize:14.0f];
        [self.contentView addSubview:coverLabel];
        
        self.selectionStyle = AQGridViewCellSelectionStyleNone;
    }
    return self;
}

- (void)updateDisplayWithImageStr:(NSString *)str text:(NSInteger)text
{
    //    NSLog(@"novelInfo:%@",_novelInfo);
    //    NSString *coverURLStr = [[_novelInfo objectForKey:@"cover_image"] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSString *coverURLStr = [[_novelInfo objectForKey:str] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    [coverImageView setImageWithURL:[NSURL URLWithString:coverURLStr] placeholderImage:[UIImage imageNamed:@"default_image"]];
    coverLabel.text = [NSString stringWithFormat:@"第%d版",text];
}

- (void)dealloc
{
    [_novelInfo release];
    [super dealloc];
}

@end
